<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import kuailiAppUser from '@/api/kuaili/kuailiAppUser'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()



const switchStatus = (statusValue, id, statusName) => {
  kuailiAppUser.changeStatus({ id, statusName, statusValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}


const options = reactive({
  id: 'kuaili_app_user',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: false,
  operationWidth: 160,
  formOption: {
    viewType: 'modal',
    width: 600
  },
  api: kuailiAppUser.getList
})

const columns = reactive([
  {
    title: "主键",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    commonRules: {
      required: true,
      message: "请输入主键"
    },
    sortable: {
      sortDirections: [
        "ascend",
        "descend"
      ],
      sorter: true
    }
  },
  {
    title: "创建者",
    dataIndex: "created_by",
    formType: "input",
    search: true,
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "更新者",
    dataIndex: "updated_by",
    formType: "input",
    search: true,
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "date",
    search: true,
    addDisplay: false,
    editDisplay: false,
    sortable: {
      sortDirections: [
        "ascend",
        "descend"
      ],
      sorter: true
    },
    showTime: true
  },
  {
    title: "更新时间",
    dataIndex: "updated_at",
    formType: "date",
    search: true,
    addDisplay: false,
    editDisplay: false,
    sortable: {
      sortDirections: [
        "ascend",
        "descend"
      ],
      sorter: true
    },
    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    search: true,
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "微信open_id",
    dataIndex: "open_id",
    formType: "input",
    hide: true,
    commonRules: {
      required: true,
      message: "请输入微信open_id"
    }
  },
  {
    title: "微信session_key",
    dataIndex: "session_key",
    formType: "input",
    hide: true,
    commonRules: {
      required: true,
      message: "请输入微信session_key"
    }
  },
  {
    title: "微信昵称",
    dataIndex: "nickname",
    formType: "input",
    search: true,
    commonRules: {
      required: true,
      message: "请输入微信昵称"
    }
  },
  {
    title: "微信头像",
    dataIndex: "avatar_url",
    formType: "upload",
    onlyData: false,
    multiple: false,
    chunk: false
  }
])
</script>
<script> export default { name: 'kuaili:appUser' } </script>